package com.nami.store.api.service;

import com.nami.store.api.request.conversation.ConverAddReq;
import com.nami.store.api.request.conversation.ConverC2CUpdRequest;
import com.nami.store.api.request.conversation.ConverItem;
import com.nami.store.api.request.conversation.ConverPageReq;
import com.nami.store.api.response.conversation.ConversationDTO;
import com.nami.store.api.response.conversation.ConverDetailVO;
import org.dromara.common.mybatis.core.page.TableDataInfo;

import java.util.List;

/**
 * 描述：
 *
 * @Author: lbc
 * @Date: 2023-08-01 15:34
 * @email: 594599620@qq.com
 * @Description: keep coding
 */
public interface RemoteConverService {

    /**
     * 注意先从redis进行获取，获取不到数据，再从mysql获取
     * 获取单个会话
     * 此处同writeCache 取得，
     * 批量获取是从另外处获取的``
     * @param appKey
     * @param userId
     * @param targetId
     * @return
     */
    ConversationDTO getConverFromCacheOrDB(String appKey, String userId, String targetId);

    ConverItem getConverFromCache(String appKey, String userId, String targetId);

    /**
     * c2c
     *
     * @param request
     * @return
     */
    boolean updPrivateChatConvers(ConverC2CUpdRequest request);

    /**
     *
     * @param itemList
     * @return
     */
    boolean updConvers(List<ConverItem> itemList);

    /**
     * get
     * 注意先从redis获取的，没有的话再从mysql获取
     *
     * @param appKey
     * @param userIds
     * @param targetId
     * @return
     */
    List<ConversationDTO> getConversFromCacheOrDb(String appKey, List<String> userIds, String targetId);

    /**
     * batch
     *
     * @param req
     * @return
     */
    boolean batchSave(List<ConverAddReq> req);

    /**
     * insertOrUpd
     *
     * @param conver
     * @return
     */
    boolean insertOrUpd(ConverItem conver);

    /**
     * write cache
     *
     * @param converItem
     * @return
     */
    boolean writeCache(ConverItem converItem);


    TableDataInfo<ConverDetailVO> getConverFromPage(ConverPageReq request);

}
